Repository navigation
fix(browser): agent clicks give your keyboard back (3/3) - #28454
Merged
Merged
Conversation
nwparker
force-pushed
the
nwparker/agent-browser-focus-3-press
branch
from
October 14, 2026 04:36
bbc5e98 to
98149a0
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-2-keys
branch
from
October 14, 2026 04:49
a895224 to
103fd93
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-3-press
branch
from
October 14, 2026 04:49
98149a0 to
4a749dd
Compare
nwparker
marked this pull request as ready for review
October 14, 2026 04:49
nwparker
force-pushed
the
nwparker/agent-browser-focus-3-press
branch
from
October 14, 2026 05:48
4a749dd to
39fa406
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-2-keys
branch
from
October 14, 2026 06:04
103fd93 to
fba4e8b
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-3-press
branch
from
October 14, 2026 06:07
39fa406 to
22b9280
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-2-keys
branch
from
October 14, 2026 06:30
fba4e8b to
9c73fee
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-3-press
branch
from
October 14, 2026 06:30
22b9280 to
9b26935
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-2-keys
branch
from
October 14, 2026 06:50
9c73fee to
ba51be1
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-3-press
branch
from
October 14, 2026 06:50
9b26935 to
8583146
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-2-keys
branch
from
October 14, 2026 07:22
ba51be1 to
5631757
Compare
nwparker
force-pushed
the
nwparker/agent-browser-focus-3-press
branch
from
October 14, 2026 07:22
8583146 to
29517fc
Compare
Any press on a <webview> guest moves Chromium focus into it, so an agent click took the user's terminal focus (#20595). Main now asks the hosting pane to guard focus for each agent press (Orca's click/mouse down and the CDP proxy) and the pane puts it back inside the webview's focus event, and again when the press ends. Offscreen pages keep their native focus.
nwparker
force-pushed
the
nwparker/agent-browser-focus-3-press
branch
from
October 14, 2026 08:13
29517fc to
aa565ae
Compare
nwparker
changed the base branch from
nwparker/agent-browser-focus-2-keys
to
main
October 14, 2026 08:13
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Oct 14, 2026
Closed
This was referenced Oct 15, 2026
brennanb2025
pushed a commit
that referenced
this pull request
Oct 15, 2026
Any press on a <webview> guest moves Chromium focus into it, so an agent click took the user's terminal focus (#20595). Main now asks the hosting pane to guard focus for each agent press (Orca's click/mouse down and the CDP proxy) and the pane puts it back inside the webview's focus event, and again when the press ends. Offscreen pages keep their native focus. (cherry picked from commit 9c0420f)
2 tasks
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When an agent clicked something in Orca's browser, your keyboard silently moved into that page, so what you typed next went to the browser instead of your terminal. Now, after an agent's click, Orca puts your keyboard back where it was. The page still behaves as if it was clicked normally.
What Changed
clickandmouse downcalledwebContents.focus()on the page before pressing.<webview>that receives a mouse press, however the press is sent.browser_focus_guard_unavailableinstead of being sent.setIgnoreMenuShortcutskeeps unhandled keys away from Orca's app menu. An agent's ⌘/Ctrl+T, ⌘/Ctrl+W or Ctrl+Tab stays in the page. In testing, synthetic input never reached those handlers anyway; the mark guarantees it.Why
Measured in a hidden Electron window: every kind of press moves focus into the
<webview>(CDP mouse, touch, tap gestures,sendInputEvent), and neitherinertnortabindexon the element stops it. So focus has to be given back. Only the renderer that hosts the page can do that, which is why main asks the pane.Putting focus back the instant it moves would make the page see a blur, and pages close menus on blur. Focus emulation plus restoring when the press ends keeps the page's menus open. The cost is the press itself, a few milliseconds during which your keystrokes can reach the page.
Offscreen rendering (#24047) would remove even that window, but rebuilds every native popup and is about 8,000 lines.
Linked Issue
Fixes #20595. Also addresses #19297, #8139 and #20533. #16674's other paths (window activation on Windows) are out of scope.
Visual Proof
N/A. Focus moves are not visible in a screenshot. The end-to-end click test is the before/after: on the PR 2 code the terminal loses focus after the agent's click (
terminalFocused: false); on this branch it keeps it.Testing
Unit:
clickandmouse downno longer focus embedded pages;End-to-end (
browser-agent-input-focus-isolation.spec.ts, run hidden):Visible window:
browser-agent-input-focus-isolation-native.spec.ts(@headful) runs the same scenarios in a window that has OS focus, then types a real OS keystroke (xdotool). The keystroke must reach the terminal, not the page.webContents.getFocusedWebContents()reports the page whenever a<webview>exists, so it can't show where typing goes. That's why the spec uses a real keystroke.xdotool.pnpm tc, suites and the changed-code quality gate pass.Platforms: hidden-window runs on macOS, Linux (Wayland) and Windows; visible-window runs on Linux (Xvfb, locally and in CI).
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Agent skill upstream boundary
Notes
browser:agentInputFocusGuard/...Ready). It carries a page id, a random token and a boolean. Replies are matched to the renderer that was asked.<webview>, so it doesn't subscribe.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)